/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  @endpointMap = {
    'ap-northeast-2-pop' = 'clickhouse.aliyuncs.com',
    'ap-southeast-1' = 'clickhouse.aliyuncs.com',
    'cn-beijing' = 'clickhouse.aliyuncs.com',
    'cn-beijing-finance-1' = 'clickhouse.aliyuncs.com',
    'cn-beijing-finance-pop' = 'clickhouse.aliyuncs.com',
    'cn-beijing-gov-1' = 'clickhouse.aliyuncs.com',
    'cn-beijing-nu16-b01' = 'clickhouse.aliyuncs.com',
    'cn-edge-1' = 'clickhouse.aliyuncs.com',
    'cn-fujian' = 'clickhouse.aliyuncs.com',
    'cn-haidian-cm12-c01' = 'clickhouse.aliyuncs.com',
    'cn-hangzhou' = 'clickhouse.aliyuncs.com',
    'cn-hangzhou-bj-b01' = 'clickhouse.aliyuncs.com',
    'cn-hangzhou-finance' = 'clickhouse.aliyuncs.com',
    'cn-hangzhou-internal-prod-1' = 'clickhouse.aliyuncs.com',
    'cn-hangzhou-internal-test-1' = 'clickhouse.aliyuncs.com',
    'cn-hangzhou-internal-test-2' = 'clickhouse.aliyuncs.com',
    'cn-hangzhou-internal-test-3' = 'clickhouse.aliyuncs.com',
    'cn-hangzhou-test-306' = 'clickhouse.aliyuncs.com',
    'cn-hongkong' = 'clickhouse.aliyuncs.com',
    'cn-hongkong-finance-pop' = 'clickhouse.aliyuncs.com',
    'cn-north-2-gov-1' = 'clickhouse.aliyuncs.com',
    'cn-qingdao' = 'clickhouse.aliyuncs.com',
    'cn-qingdao-nebula' = 'clickhouse.aliyuncs.com',
    'cn-shanghai' = 'clickhouse.aliyuncs.com',
    'cn-shanghai-et15-b01' = 'clickhouse.aliyuncs.com',
    'cn-shanghai-et2-b01' = 'clickhouse.aliyuncs.com',
    'cn-shanghai-finance-1' = 'clickhouse.aliyuncs.com',
    'cn-shanghai-inner' = 'clickhouse.aliyuncs.com',
    'cn-shanghai-internal-test-1' = 'clickhouse.aliyuncs.com',
    'cn-shenzhen' = 'clickhouse.aliyuncs.com',
    'cn-shenzhen-finance-1' = 'clickhouse.aliyuncs.com',
    'cn-shenzhen-inner' = 'clickhouse.aliyuncs.com',
    'cn-shenzhen-st4-d01' = 'clickhouse.aliyuncs.com',
    'cn-shenzhen-su18-b01' = 'clickhouse.aliyuncs.com',
    'cn-wuhan' = 'clickhouse.aliyuncs.com',
    'cn-yushanfang' = 'clickhouse.aliyuncs.com',
    'cn-zhangbei-na61-b01' = 'clickhouse.aliyuncs.com',
    'cn-zhangjiakou-na62-a01' = 'clickhouse.aliyuncs.com',
    'cn-zhengzhou-nebula-1' = 'clickhouse.aliyuncs.com',
    'eu-west-1-oxs' = 'clickhouse.aliyuncs.com',
    'me-east-1' = 'clickhouse.aliyuncs.com',
    'rus-west-1-pop' = 'clickhouse.aliyuncs.com',
    'us-east-1' = 'clickhouse.aliyuncs.com',
    'us-west-1' = 'clickhouse.aliyuncs.com',
  };

  checkConfig(config);
  @endpoint = getEndpoint('clickhouse', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model CreateAccountRequest {
  account?: string(name='Account', description='The name of the account.

This parameter is required.', example='test1'),
  accountType?: string(name='AccountType', description='The type of the database account. Valid values:

*   **NormalAccount**: standard account
*   **SuperAccount**: privileged account

This parameter is required.', example='NormalAccount'),
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-bp100p4q1g9z3****'),
  description?: string(name='Description', description='The description of the account.', example='Used for account'),
  dmlAuthSetting?: {
    allowDatabases?: [ string ](name='AllowDatabases', description='The databases on which you want to grant permissions. Separate multiple databases with commas (,).'),
    allowDictionaries?: [ string ](name='AllowDictionaries', description='The dictionaries on which you want to grant permissions. Separate multiple dictionaries with commas (,).'),
    ddlAuthority?: boolean(name='DdlAuthority', description='Specifies whether to grant the DDL permissions to the database account. Valid values:

*   **true**: The account has the permissions to execute DDL statements.
*   **false**: The account does not have the permissions to execute DDL statements.', example='true'),
    dmlAuthority?: int32(name='DmlAuthority', description='Specifies whether to grant the DML permissions to the database account. Valid values:

*   **0**: The account has the permissions to read data from the database, write data to the database, and modify the settings of the database.
*   **1**: The account only has the permissions to read data from the database.
*   **2**: The account only has the permissions to read data from the database and modify the settings of the database.', example='0'),
  }(name='DmlAuthSetting', description='The information about permissions.'),
  password?: string(name='Password', description='The password of the database account. The password must meet the following requirements:

- The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters.
- The following special characters are supported: ! @ # $ % ^ & * ( ) _ + - =
- The password must be 8 to 32 characters in length.

This parameter is required.', example='a1b2c3d4@'),
  product?: string(name='Product', description='The code of the cloud service.', example='clickhouse'),
  regionId?: string(name='RegionId', description='The region ID.

This parameter is required.', example='cn-hangzhou'),
}

model CreateAccountShrinkRequest {
  account?: string(name='Account', description='The name of the account.

This parameter is required.', example='test1'),
  accountType?: string(name='AccountType', description='The type of the database account. Valid values:

*   **NormalAccount**: standard account
*   **SuperAccount**: privileged account

This parameter is required.', example='NormalAccount'),
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-bp100p4q1g9z3****'),
  description?: string(name='Description', description='The description of the account.', example='Used for account'),
  dmlAuthSettingShrink?: string(name='DmlAuthSetting', description='The information about permissions.'),
  password?: string(name='Password', description='The password of the database account. The password must meet the following requirements:

- The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters.
- The following special characters are supported: ! @ # $ % ^ & * ( ) _ + - =
- The password must be 8 to 32 characters in length.

This parameter is required.', example='a1b2c3d4@'),
  product?: string(name='Product', description='The code of the cloud service.', example='clickhouse'),
  regionId?: string(name='RegionId', description='The region ID.

This parameter is required.', example='cn-hangzhou'),
}

model CreateAccountResponseBody = {
  data?: {
    account?: string(name='Account', description='The name of the database account.', example='test1'),
    DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.', example='cc-bp100p4q1g9z3****'),
  }(name='Data', description='The data returned.'),
  requestId?: string(name='RequestId', description='The request ID.', example='2FED790E-FB61-4721-8C1C-07C627FA5A19'),
}

model CreateAccountResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateAccountResponseBody(name='body'),
}

/**
 * @summary Creates a database account for an ApsaraDB for ClickHouse Enterprise Edition cluster.
 *
 * @param tmpReq CreateAccountRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateAccountResponse
 */
async function createAccountWithOptions(tmpReq: CreateAccountRequest, runtime: Util.RuntimeOptions): CreateAccountResponse {
  Util.validateModel(tmpReq);
  var request = new CreateAccountShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.dmlAuthSetting)) {
    request.dmlAuthSettingShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.dmlAuthSetting, 'DmlAuthSetting', 'json');
  }
  var query = {};
  if (!Util.isUnset(request.account)) {
    query['Account'] = request.account;
  }
  if (!Util.isUnset(request.accountType)) {
    query['AccountType'] = request.accountType;
  }
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.description)) {
    query['Description'] = request.description;
  }
  if (!Util.isUnset(request.dmlAuthSettingShrink)) {
    query['DmlAuthSetting'] = request.dmlAuthSettingShrink;
  }
  if (!Util.isUnset(request.password)) {
    query['Password'] = request.password;
  }
  if (!Util.isUnset(request.product)) {
    query['Product'] = request.product;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateAccount',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Creates a database account for an ApsaraDB for ClickHouse Enterprise Edition cluster.
 *
 * @param request CreateAccountRequest
 * @return CreateAccountResponse
 */
async function createAccount(request: CreateAccountRequest): CreateAccountResponse {
  var runtime = new Util.RuntimeOptions{};
  return createAccountWithOptions(request, runtime);
}

model CreateDBRequest {
  comment?: string(name='Comment', description='Database remark information.', example='test'),
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-bp100p4q1g9z3****'),
  DBName?: string(name='DBName', description='The database name. The name must meet the following requirements:

*   The name can contain lowercase letters, digits, underscores (_), and hyphens (-).
*   The name must start with a lowercase letter and end with a lowercase letter or digit.
*   The name can be up to 64 characters in length.

>  An underscore (_) is counted as two characters.

This parameter is required.', example='testdb001'),
  regionId?: string(name='RegionId', description='The region ID.

This parameter is required.', example='cn-hangzhou'),
}

model CreateDBResponseBody = {
  data?: {
    DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.', example='cc-bp100p4q1g9z3****'),
    DBName?: string(name='DBName', description='The name of the database.', example='testdb001'),
  }(name='Data', description='The data returned.'),
  requestId?: string(name='RequestId', description='The request ID.', example='94F92113-FF63-5E57-8401-6FE123AD11DD'),
}

model CreateDBResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateDBResponseBody(name='body'),
}

/**
 * @summary Creates an ApsaraDB for ClickHouse database.
 *
 * @param request CreateDBRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateDBResponse
 */
async function createDBWithOptions(request: CreateDBRequest, runtime: Util.RuntimeOptions): CreateDBResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.comment)) {
    query['Comment'] = request.comment;
  }
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.DBName)) {
    query['DBName'] = request.DBName;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateDB',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Creates an ApsaraDB for ClickHouse database.
 *
 * @param request CreateDBRequest
 * @return CreateDBResponse
 */
async function createDB(request: CreateDBRequest): CreateDBResponse {
  var runtime = new Util.RuntimeOptions{};
  return createDBWithOptions(request, runtime);
}

model CreateDBInstanceRequest {
  backupSetId?: string(name='BackupSetId', description='The backup set ID.', example='1'),
  clientToken?: string(name='ClientToken', description='The client token that is used to ensure the idempotence of the request. You can use the client to generate the token. Make sure that the token is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length.', example='AB'),
  DBInstanceDescription?: string(name='DBInstanceDescription', description='The cluster description.', example='Used for test'),
  deploySchema?: string(name='DeploySchema', description='The deployment status of the cluster.', example='multi_az'),
  engine?: string(name='Engine', description='The engine type.

Valid values:

*   clickhouse', example='clickhouse'),
  engineVersion?: string(name='EngineVersion', description='The engine version.', example='23.8'),
  multiZone?: [ 
    {
      vSwitchIds?: [ string ](name='VSwitchIds', description='The vSwitch IDs.'),
      zoneId?: string(name='ZoneId', description='The zone ID.', example='cn-hangzhou-h'),
    }
  ](name='MultiZone', description='The configurations of multi-zone deployment.'),
  regionId?: string(name='RegionId', description='The region ID

This parameter is required.', example='cn-hangzhou'),
  resourceGroupId?: string(name='ResourceGroupId'),
  scaleMax?: string(name='ScaleMax', description='The maximum capacity for auto scaling.', example='32'),
  scaleMin?: string(name='ScaleMin', description='The minimum capacity for auto scaling.', example='8'),
  sourceDBInstanceId?: string(name='SourceDBInstanceId', description='The cluster ID.', example='cc-2ze1*********'),
  vpcId?: string(name='VpcId', description='The virtual private cloud (VPC) ID.', example='vpc-uf6xmupdn7v6ui9f****'),
  vswitchId?: string(name='VswitchId', description='The vSwitch ID.', example='vsw-uf632qye9oqt4x4sr****'),
  zoneId?: string(name='ZoneId', description='The zone ID.', example='cn-hangzhou-h'),
}

model CreateDBInstanceShrinkRequest {
  backupSetId?: string(name='BackupSetId', description='The backup set ID.', example='1'),
  clientToken?: string(name='ClientToken', description='The client token that is used to ensure the idempotence of the request. You can use the client to generate the token. Make sure that the token is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length.', example='AB'),
  DBInstanceDescription?: string(name='DBInstanceDescription', description='The cluster description.', example='Used for test'),
  deploySchema?: string(name='DeploySchema', description='The deployment status of the cluster.', example='multi_az'),
  engine?: string(name='Engine', description='The engine type.

Valid values:

*   clickhouse', example='clickhouse'),
  engineVersion?: string(name='EngineVersion', description='The engine version.', example='23.8'),
  multiZoneShrink?: string(name='MultiZone', description='The configurations of multi-zone deployment.'),
  regionId?: string(name='RegionId', description='The region ID

This parameter is required.', example='cn-hangzhou'),
  resourceGroupId?: string(name='ResourceGroupId'),
  scaleMax?: string(name='ScaleMax', description='The maximum capacity for auto scaling.', example='32'),
  scaleMin?: string(name='ScaleMin', description='The minimum capacity for auto scaling.', example='8'),
  sourceDBInstanceId?: string(name='SourceDBInstanceId', description='The cluster ID.', example='cc-2ze1*********'),
  vpcId?: string(name='VpcId', description='The virtual private cloud (VPC) ID.', example='vpc-uf6xmupdn7v6ui9f****'),
  vswitchId?: string(name='VswitchId', description='The vSwitch ID.', example='vsw-uf632qye9oqt4x4sr****'),
  zoneId?: string(name='ZoneId', description='The zone ID.', example='cn-hangzhou-h'),
}

model CreateDBInstanceResponseBody = {
  data?: {
    connectionString?: string(name='ConnectionString', description='The endpoint.', example='cc-bp100p4q1g9z3****-clickhouse.clickhouseserver.rds.aliyuncs.com'),
    DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.', example='cc-bp100p4q1g9z3****'),
    orderId?: long(name='OrderId', description='The order ID.', example='21154955706****'),
  }(name='Data', description='The response parameters.'),
  requestId?: string(name='RequestId', description='The request ID.', example='F5178C10-1407-4987-9133-DE4DC9119F75'),
}

model CreateDBInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateDBInstanceResponseBody(name='body'),
}

/**
 * @summary Creates an ApsaraDB for ClickHouse cluster that runs Enterprise Edition.
 *
 * @param tmpReq CreateDBInstanceRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateDBInstanceResponse
 */
async function createDBInstanceWithOptions(tmpReq: CreateDBInstanceRequest, runtime: Util.RuntimeOptions): CreateDBInstanceResponse {
  Util.validateModel(tmpReq);
  var request = new CreateDBInstanceShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.multiZone)) {
    request.multiZoneShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.multiZone, 'MultiZone', 'json');
  }
  var query = {};
  if (!Util.isUnset(request.backupSetId)) {
    query['BackupSetId'] = request.backupSetId;
  }
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.DBInstanceDescription)) {
    query['DBInstanceDescription'] = request.DBInstanceDescription;
  }
  if (!Util.isUnset(request.deploySchema)) {
    query['DeploySchema'] = request.deploySchema;
  }
  if (!Util.isUnset(request.engine)) {
    query['Engine'] = request.engine;
  }
  if (!Util.isUnset(request.engineVersion)) {
    query['EngineVersion'] = request.engineVersion;
  }
  if (!Util.isUnset(request.multiZoneShrink)) {
    query['MultiZone'] = request.multiZoneShrink;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceGroupId)) {
    query['ResourceGroupId'] = request.resourceGroupId;
  }
  if (!Util.isUnset(request.scaleMax)) {
    query['ScaleMax'] = request.scaleMax;
  }
  if (!Util.isUnset(request.scaleMin)) {
    query['ScaleMin'] = request.scaleMin;
  }
  if (!Util.isUnset(request.sourceDBInstanceId)) {
    query['SourceDBInstanceId'] = request.sourceDBInstanceId;
  }
  if (!Util.isUnset(request.vpcId)) {
    query['VpcId'] = request.vpcId;
  }
  if (!Util.isUnset(request.vswitchId)) {
    query['VswitchId'] = request.vswitchId;
  }
  if (!Util.isUnset(request.zoneId)) {
    query['ZoneId'] = request.zoneId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateDBInstance',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Creates an ApsaraDB for ClickHouse cluster that runs Enterprise Edition.
 *
 * @param request CreateDBInstanceRequest
 * @return CreateDBInstanceResponse
 */
async function createDBInstance(request: CreateDBInstanceRequest): CreateDBInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return createDBInstanceWithOptions(request, runtime);
}

model CreateEndpointRequest {
  connectionPrefix?: string(name='ConnectionPrefix', description='The prefix of the new endpoint. The prefix of the ConnectionString parameter.', example='cc-bp100p4q1g9z3****-clickhouse.clickhouseserver.rds.aliyuncs.com'),
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-bp100p4q1g9z3****'),
  DBInstanceNetType?: string(name='DBInstanceNetType', description='The network type.

Valid values:

*   Public', example='Public'),
  regionId?: string(name='RegionId', description='The region ID.

This parameter is required.', example='cn-hangzhou'),
}

model CreateEndpointResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='2FED790E-FB61-4721-8C1C-07C627FA5A19'),
}

model CreateEndpointResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateEndpointResponseBody(name='body'),
}

/**
 * @summary Applies for a public endpoint.
 *
 * @param request CreateEndpointRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateEndpointResponse
 */
async function createEndpointWithOptions(request: CreateEndpointRequest, runtime: Util.RuntimeOptions): CreateEndpointResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.connectionPrefix)) {
    query['ConnectionPrefix'] = request.connectionPrefix;
  }
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.DBInstanceNetType)) {
    query['DBInstanceNetType'] = request.DBInstanceNetType;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateEndpoint',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Applies for a public endpoint.
 *
 * @param request CreateEndpointRequest
 * @return CreateEndpointResponse
 */
async function createEndpoint(request: CreateEndpointRequest): CreateEndpointResponse {
  var runtime = new Util.RuntimeOptions{};
  return createEndpointWithOptions(request, runtime);
}

model DeleteAccountRequest {
  account?: string(name='Account', description='The destination database account.

This parameter is required.', example='test'),
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-bp100p4q1g9z3****'),
  product?: string(name='Product', description='The code of the cloud service.', example='clickhouse'),
  regionId?: string(name='RegionId', description='The region ID.

This parameter is required.', example='cn-hangzhou'),
}

model DeleteAccountResponseBody = {
  data?: {
    account?: string(name='Account', description='The name of the account.', example='test1'),
    DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.', example='cc-bp100p4q1g9z3****'),
  }(name='Data', description='The data returned.'),
  requestId?: string(name='RequestId', description='The request ID.', example='21D06907-CEA5-561D-B6B1-198BCCE99ED1'),
}

model DeleteAccountResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteAccountResponseBody(name='body'),
}

/**
 * @summary Deletes a database account from an ApsaraDB for ClickHouse cluster.
 *
 * @param request DeleteAccountRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteAccountResponse
 */
async function deleteAccountWithOptions(request: DeleteAccountRequest, runtime: Util.RuntimeOptions): DeleteAccountResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.account)) {
    query['Account'] = request.account;
  }
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.product)) {
    query['Product'] = request.product;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeleteAccount',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Deletes a database account from an ApsaraDB for ClickHouse cluster.
 *
 * @param request DeleteAccountRequest
 * @return DeleteAccountResponse
 */
async function deleteAccount(request: DeleteAccountRequest): DeleteAccountResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteAccountWithOptions(request, runtime);
}

model DeleteDBRequest {
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-bp100p4q1g9z3****'),
  DBName?: string(name='DBName', description='The name of the destination database.

This parameter is required.', example='testdb001'),
  regionId?: string(name='RegionId', description='The region ID.

This parameter is required.', example='cn-hangzhou'),
}

model DeleteDBResponseBody = {
  data?: {
    DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.', example='cc-bp100p4q1g9z3****'),
    DBName?: string(name='DBName', description='The name of the database.', example='testdb001'),
  }(name='Data', description='The data returned.'),
  requestId?: string(name='RequestId', description='The request ID.', example='06798FEE-BEF2-5FAF-A30D-728973BBE97C'),
}

model DeleteDBResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteDBResponseBody(name='body'),
}

/**
 * @summary Deletes an ApsaraDB for ClickHouse database.
 *
 * @param request DeleteDBRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteDBResponse
 */
async function deleteDBWithOptions(request: DeleteDBRequest, runtime: Util.RuntimeOptions): DeleteDBResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.DBName)) {
    query['DBName'] = request.DBName;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeleteDB',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Deletes an ApsaraDB for ClickHouse database.
 *
 * @param request DeleteDBRequest
 * @return DeleteDBResponse
 */
async function deleteDB(request: DeleteDBRequest): DeleteDBResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteDBWithOptions(request, runtime);
}

model DeleteDBInstanceRequest {
  DBInstanceId?: string(name='DBInstanceId', description='The ID of the destination cluster.

This parameter is required.', example='cc-bp100p4q1g9z3****'),
  regionId?: string(name='RegionId', description='The region ID.', example='cn-hangzhou'),
}

model DeleteDBInstanceResponseBody = {
  data?: {
    DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.', example='cc-bp100p4q1g9z3****'),
  }(name='Data', description='The data returned.'),
  requestId?: string(name='RequestId', description='The request ID.', example='D0CEC6AC-7760-409A-A0D5-E6CD8660E9CC'),
}

model DeleteDBInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteDBInstanceResponseBody(name='body'),
}

/**
 * @summary Releases an ApsaraDB for ClickHouse Enterprise Edition cluster.
 *
 * @param request DeleteDBInstanceRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteDBInstanceResponse
 */
async function deleteDBInstanceWithOptions(request: DeleteDBInstanceRequest, runtime: Util.RuntimeOptions): DeleteDBInstanceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeleteDBInstance',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Releases an ApsaraDB for ClickHouse Enterprise Edition cluster.
 *
 * @param request DeleteDBInstanceRequest
 * @return DeleteDBInstanceResponse
 */
async function deleteDBInstance(request: DeleteDBInstanceRequest): DeleteDBInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteDBInstanceWithOptions(request, runtime);
}

model DeleteEndpointRequest {
  connectionString?: string(name='ConnectionString', description='The prefix of the endpoint, which indicates the prefix of the value of the ConnectionString parameter.', example='cc-bp100p4q1g9z3****-clickhouse.clickhouseserver.rds.aliyuncs.com'),
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-bp100p4q1g9z3****'),
  DBInstanceNetType?: string(name='DBInstanceNetType'),
  regionId?: string(name='RegionId', description='The region ID.', example='cn-hangzhou'),
}

model DeleteEndpointResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='F5178C10-1407-4987-9133-DE4DC9119F75'),
}

model DeleteEndpointResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteEndpointResponseBody(name='body'),
}

/**
 * @summary Releases a public endpoint.
 *
 * @param request DeleteEndpointRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteEndpointResponse
 */
async function deleteEndpointWithOptions(request: DeleteEndpointRequest, runtime: Util.RuntimeOptions): DeleteEndpointResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.connectionString)) {
    query['ConnectionString'] = request.connectionString;
  }
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.DBInstanceNetType)) {
    query['DBInstanceNetType'] = request.DBInstanceNetType;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeleteEndpoint',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Releases a public endpoint.
 *
 * @param request DeleteEndpointRequest
 * @return DeleteEndpointResponse
 */
async function deleteEndpoint(request: DeleteEndpointRequest): DeleteEndpointResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteEndpointWithOptions(request, runtime);
}

model DescribeAccountAuthorityRequest {
  account?: string(name='Account', description='The name of the database account.

This parameter is required.', example='test1'),
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-bp100p4q1g9z3****'),
  regionId?: string(name='RegionId', description='The region ID

This parameter is required.', example='cn-hangzhou'),
}

model DescribeAccountAuthorityResponseBody = {
  data?: {
    account?: string(name='Account', description='The name of the database account.', example='test1'),
    allowDatabases?: [ string ](name='AllowDatabases', description='The databases on which permissions are granted.'),
    allowDictionaries?: [ string ](name='AllowDictionaries', description='The dictionaries on which permissions are granted.'),
    DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.', example='cc-bp100p4q1g9z3****'),
    ddlAuthority?: boolean(name='DdlAuthority', description='Indicates whether the DDL permissions are granted to the database account. Valid values:

*   **true**: The account has the permissions to execute DDL statements.
*   **false**: The account does not have the permissions to execute DDL statements.', example='true'),
    dmlAuthority?: int32(name='DmlAuthority', description='Indicates whether the DML permissions are granted to the database account. Valid values:

*   0: The account has the permissions to read data from the database, write data to the database, and modify the settings of the database.
*   1: The account only has the permissions to read data from the database.
*   2: The account only has the permissions to read data from the database and modify the settings of the database.', example='0'),
    totalDatabases?: [ string ](name='TotalDatabases', description='All databases.'),
    totalDictionaries?: [ string ](name='TotalDictionaries', description='The database.'),
  }(name='Data', description='The returned result.'),
  requestId?: string(name='RequestId', description='The request ID.', example='F5178C10-1407-4987-9133-DE4DC9119F75'),
}

model DescribeAccountAuthorityResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeAccountAuthorityResponseBody(name='body'),
}

/**
 * @summary Queries the permissions of a database account.
 *
 * @param request DescribeAccountAuthorityRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeAccountAuthorityResponse
 */
async function describeAccountAuthorityWithOptions(request: DescribeAccountAuthorityRequest, runtime: Util.RuntimeOptions): DescribeAccountAuthorityResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.account)) {
    query['Account'] = request.account;
  }
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeAccountAuthority',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries the permissions of a database account.
 *
 * @param request DescribeAccountAuthorityRequest
 * @return DescribeAccountAuthorityResponse
 */
async function describeAccountAuthority(request: DescribeAccountAuthorityRequest): DescribeAccountAuthorityResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeAccountAuthorityWithOptions(request, runtime);
}

model DescribeAccountsRequest {
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-bp100p4q1g9z3****'),
  pageNumber?: string(name='PageNumber', description='The page number.', example='1'),
  pageSize?: string(name='PageSize', description='The number of entries per page. Valid values:

*   **30** (default)
*   **50**
*   **100**', example='30'),
  product?: string(name='Product', description='The code of the cloud service.', example='clickhouse'),
  regionId?: string(name='RegionId', description='The region ID.', example='cn-hangzhou'),
}

model DescribeAccountsResponseBody = {
  data?: {
    accounts?: [ 
      {
        account?: string(name='Account', description='The username of the database account.', example='test'),
        accountType?: string(name='AccountType', description='The type of the database account. Valid values:

*   **1**: standard account
*   **6**: privileged account', example='NormalAccount'),
        description?: string(name='Description', description='The description.', example='Used for test'),
        status?: string(name='Status', description='The state of the database account. Valid values:

*   **0**: The database account is being created.
*   **1**: The database account is in use.
*   **3**: The database account is being deleted.', example='1'),
      }
    ](name='Accounts', description='The database accounts.'),
    pageNumber?: int32(name='PageNumber', description='The page number.', example='1'),
    pageSize?: int32(name='PageSize', description='The number of entries per page. Valid values:

*   **30** (default)
*   **50**
*   **100**', example='30'),
    totalCount?: int32(name='TotalCount', description='The total number of entries returned.', example='1'),
  }(name='Data', description='The result returned.'),
  requestId?: string(name='RequestId', description='The request ID.', example='F5178C10-1407-4987-9133-DE4DC9119F75'),
}

model DescribeAccountsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeAccountsResponseBody(name='body'),
}

/**
 * @summary Queries database accounts for an ApsaraDB for ClickHouse cluster.
 *
 * @param request DescribeAccountsRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeAccountsResponse
 */
async function describeAccountsWithOptions(request: DescribeAccountsRequest, runtime: Util.RuntimeOptions): DescribeAccountsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.pageNumber)) {
    query['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.product)) {
    query['Product'] = request.product;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeAccounts',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries database accounts for an ApsaraDB for ClickHouse cluster.
 *
 * @param request DescribeAccountsRequest
 * @return DescribeAccountsResponse
 */
async function describeAccounts(request: DescribeAccountsRequest): DescribeAccountsResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeAccountsWithOptions(request, runtime);
}

model DescribeDBInstanceAttributeRequest {
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-bp100p4q1g9z3****'),
  regionId?: string(name='RegionId', description='The region ID.

Valid values:

*   cn-beijing', example='cn-hangzhou'),
}

model DescribeDBInstanceAttributeResponseBody = {
  data?: {
    aliUid?: long(name='AliUid', description='The ID of the Alibaba Cloud account.', example='140692647406****'),
    bid?: string(name='Bid', description='The channel ID.', example='PD39050615820269****'),
    chargeType?: string(name='ChargeType', description='The billing method. Enterprise Edition clusters use the pay-as-you-go billing method.', example='PrePaid'),
    createTime?: string(name='CreateTime', description='The time when the cluster was created. The time follows the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format.', example='2023-09-14T08:14:48Z'),
    DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.', example='cc-bp100p4q1g9z3****'),
    deletionProtection?: boolean(name='DeletionProtection', description='Indicates whether the release protection feature is enabled for the cluster.', example='0/1'),
    deploySchema?: string(name='DeploySchema', description='The deployment mode of the cluster. Valid values: single_az and multi_az.

*   single_az: indicates that the server nodes are deployed in the primary zone. The ID of the primary zone is specified by the ZoneID parameter.
*   multi_az: indicates that the server nodes are deployed in multiple zones. The information about the zones is specified by the MultiZones parameter.

The keeper nodes are deployed in multiple zones.', example='single_az'),
    description?: string(name='Description', description='The cluster description.', example='Used for test'),
    disabledPorts?: string(name='DisabledPorts', description='The disabled database ports. Multiple database ports are separated by commas (,).', example='9001,8123'),
    engine?: string(name='Engine', description='The engine type.', example='clickhouse'),
    engineMinorVersion?: string(name='EngineMinorVersion', description='The minor engine version of the cluster.', example='23.8.1.41495_6'),
    engineVersion?: string(name='EngineVersion', description='The engine version.', example='23.8'),
    expireTime?: string(name='ExpireTime', description='The time when the cluster expires. The time follows the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format.

>  Pay-as-you-go clusters never expire. If the cluster is a pay-as-you-go cluster, an empty string is returned for this parameter.', example='2024-04-17T08:14:48Z'),
    latestEngineMinorVersion?: string(name='LatestEngineMinorVersion', description='The latest minor engine version.', example='23.8.1.41495_6'),
    lockMode?: string(name='LockMode', description='The lock mode of the cluster.', example='0'),
    lockReason?: string(name='LockReason', description='The reason why the cluster was locked.', example='nolock'),
    maintainEndTime?: string(name='MaintainEndTime', description='The end time of the maintenance window.', example='21:00'),
    maintainStartTime?: string(name='MaintainStartTime', description='The start time of the maintenance window.', example='12:00'),
    multiZones?: [ 
      {
        vSwitchIds?: [ string ](name='VSwitchIds', description='The vSwitch IDs.'),
        zoneId?: string(name='ZoneId', description='The zone ID.', example='cn-hangzhou-h'),
      }
    ](name='MultiZones', description='The information about the zones.'),
    nodes?: [ 
      {
        nodeStatus?: string(name='NodeStatus', description='The node status.', example='active'),
        zoneId?: string(name='ZoneId', description='The zone ID.', example='cn-hangzhou-h'),
      }
    ](name='Nodes', description='The nodes.'),
    objectStoreSize?: string(name='ObjectStoreSize', description='The size of the object storage space.', example='13'),
    regionId?: string(name='RegionId', description='The region ID.', example='cn-hangzhou'),
    resourceGroupId?: string(name='ResourceGroupId', description='The resource ID.', example='rg-acfmzygvt54****'),
    scaleMax?: int32(name='ScaleMax', description='The maximum capacity for elastic scaling.', example='32'),
    scaleMin?: int32(name='ScaleMin', description='The minimum capacity for elastic scaling.', example='8'),
    status?: string(name='Status', description='The cluster status.', example='active'),
    storageSize?: int32(name='StorageSize', description='The size of the storage space. Unit: GB.', example='12'),
    storageType?: string(name='StorageType', description='The storage type.', example='100'),
    tags?: [ 
      {
        key?: string(name='Key', description='The key of the tag.', example='id'),
        value?: string(name='Value', description='The value of the tag.', example='ck'),
      }
    ](name='Tags', description='The details of the tags.'),
    vSwitchId?: string(name='VSwitchId', description='The vSwitch ID.', example='vsw-uf67ij56zm9x4uc6hmilg'),
    vpcId?: string(name='VpcId', description='The virtual private cloud (VPC) ID.', example='vpc-wz9duj8xd6r1gzhsg*****'),
    zoneId?: string(name='ZoneId', description='The zone ID.', example='cn-hangzhou-h'),
  }(name='Data', description='The result returned.'),
  requestId?: string(name='RequestId', description='The request ID.', example='2FED790E-FB61-4721-8C1C-07C627FA5A19'),
}

model DescribeDBInstanceAttributeResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeDBInstanceAttributeResponseBody(name='body'),
}

/**
 * @summary Queries the details of an ApsaraDB for ClickHouse cluster that runs Enterprise Edition.
 *
 * @param request DescribeDBInstanceAttributeRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeDBInstanceAttributeResponse
 */
async function describeDBInstanceAttributeWithOptions(request: DescribeDBInstanceAttributeRequest, runtime: Util.RuntimeOptions): DescribeDBInstanceAttributeResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeDBInstanceAttribute',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries the details of an ApsaraDB for ClickHouse cluster that runs Enterprise Edition.
 *
 * @param request DescribeDBInstanceAttributeRequest
 * @return DescribeDBInstanceAttributeResponse
 */
async function describeDBInstanceAttribute(request: DescribeDBInstanceAttributeRequest): DescribeDBInstanceAttributeResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeDBInstanceAttributeWithOptions(request, runtime);
}

model DescribeDBInstanceDataSourcesRequest {
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-bp100p4q1g9z3****'),
  DBName?: string(name='DBName', description='The database name.', example='dbtest'),
  regionId?: string(name='RegionId', description='The region ID.', example='cn-hangzhou'),
  tableName?: string(name='TableName', description='The table name.', example='tableTest'),
}

model DescribeDBInstanceDataSourcesResponseBody = {
  data?: {
    columns?: [ 
      {
        columnName?: string(name='ColumnName', description='The column name.', example='c31'),
        comment?: string(name='Comment', description='The description of the database account.', example='Used for test'),
        DBName?: string(name='DBName', description='The database name.', example='dbtest'),
        primaryKey?: string(name='PrimaryKey', description='Indicates whether the column is the primary key of the table. Valid values:

*   **true**
*   **false**', example='false'),
        tableName?: string(name='TableName', description='The table name.', example='tableTest'),
        type?: string(name='Type', description='The type of the stored data.', example='UInt64'),
      }
    ](name='Columns', description='The columns.'),
    DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.', example='cc-bp100p4q1g9z3****'),
    schemas?: string(name='Schemas', description='The account.', example='default'),
    tables?: [ string ](name='Tables', description='The tables.'),
  }(name='Data', description='The returned result.'),
  requestId?: string(name='RequestId', description='The request ID.', example='F543E6CC-6868-523D-8D28-0E92CF977ED2'),
}

model DescribeDBInstanceDataSourcesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeDBInstanceDataSourcesResponseBody(name='body'),
}

/**
 * @summary Queries the schema of a database or a table.
 *
 * @param request DescribeDBInstanceDataSourcesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeDBInstanceDataSourcesResponse
 */
async function describeDBInstanceDataSourcesWithOptions(request: DescribeDBInstanceDataSourcesRequest, runtime: Util.RuntimeOptions): DescribeDBInstanceDataSourcesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.DBName)) {
    query['DBName'] = request.DBName;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.tableName)) {
    query['TableName'] = request.tableName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeDBInstanceDataSources',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries the schema of a database or a table.
 *
 * @param request DescribeDBInstanceDataSourcesRequest
 * @return DescribeDBInstanceDataSourcesResponse
 */
async function describeDBInstanceDataSources(request: DescribeDBInstanceDataSourcesRequest): DescribeDBInstanceDataSourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeDBInstanceDataSourcesWithOptions(request, runtime);
}

model DescribeDBInstancesRequest {
  DBInstanceIds?: string(name='DBInstanceIds', description='The cluster IDs. Separate multiple cluster IDs with commas (,).', example='cc-xxxxx,cx-xxxx'),
  DBInstanceStatus?: string(name='DBInstanceStatus', description='The cluster status.', example='active'),
  description?: string(name='Description', description='The cluster description.', example='test'),
  pageNumber?: int32(name='PageNumber', description='The page number.', example='1'),
  pageSize?: int32(name='PageSize', description='The number of entries per page.', example='30'),
  regionId?: string(name='RegionId', description='The region ID.', example='cn-hangzhou'),
  resourceGroupId?: string(name='ResourceGroupId', description='The resource group ID.', example='rg-4690g37929****'),
}

model DescribeDBInstancesResponseBody = {
  data?: {
    DBInstances?: [ 
      {
        aliUid?: string(name='AliUid', description='The user ID.', example='1294****'),
        bid?: string(name='Bid', description='The channel ID.', example='186681****'),
        chargeType?: string(name='ChargeType', description='The billing method. Valid values:

*   PrePaid: subscription
*   PostPaid: pay-as-you-go', example='PostPaid'),
        createTime?: string(name='CreateTime', description='The time when the cluster was created.', example='2022-12-04 21:16:15'),
        DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.', example='cc-xxxxxxx'),
        deletionProtection?: string(name='DeletionProtection', description='Indicates whether the release protection feature is enabled for the cluster.', example='False'),
        description?: string(name='Description', description='The cluster description.', example='test_desc'),
        engine?: string(name='Engine', description='The engine type.', example='clickhouse'),
        engineVersion?: string(name='EngineVersion', description='The engine version.', example='22.8'),
        expireTime?: string(name='ExpireTime', description='The time when the cluster expires.', example='2024-02-16 11:51:06'),
        lockMode?: string(name='LockMode', description='The lock mode.', example='0'),
        lockReason?: string(name='LockReason', description='The reason why the cluster was locked.', example='null'),
        maintainEndTime?: string(name='MaintainEndTime', description='The end time of the maintenance window.', example='04:00:00Z'),
        maintainStartTime?: string(name='MaintainStartTime', description='The start time of the maintenance window.', example='00:00Z'),
        regionId?: string(name='RegionId', description='The region ID.', example='cn-hangzhou'),
        resourceGroupId?: string(name='ResourceGroupId', description='The resource group ID.', example='rg-acfmzy****'),
        scaleMax?: int32(name='ScaleMax', description='The maximum capacity for elastic scaling.', example='13'),
        scaleMin?: int32(name='ScaleMin', description='The minimum capacity for elastic scaling.', example='1'),
        status?: string(name='Status', description='The cluster status.', example='active'),
        tags?: [ 
          {
            key?: string(name='Key', description='The tag key.', example='tag'),
            value?: string(name='Value', description='The tag value.', example='test'),
          }
        ](name='Tags', description='The tags.'),
        vSwitchId?: string(name='VSwitchId', description='The vSwitch ID.', example='vsw-8vb5mw****'),
        vpcId?: string(name='VpcId', description='The virtual private cloud (VPC) ID.', example='vpc-uf6kg****'),
        zoneId?: string(name='ZoneId', description='The zone ID.', example='cn-hangzhou-i'),
      }
    ](name='DBInstances', description='The clusters.'),
    pageNumber?: int32(name='PageNumber', description='The page number.', example='1'),
    pageSize?: int32(name='PageSize', description='The number of entries per page.', example='30'),
    totalCount?: string(name='TotalCount', description='The total number of entries returned.', example='1'),
  }(name='Data', description='The returned result.'),
  requestId?: string(name='RequestId', description='The request ID.', example='xxx-xxx-xxx'),
}

model DescribeDBInstancesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeDBInstancesResponseBody(name='body'),
}

/**
 * @summary Queries a list of ApsaraDB for ClickHouse clusters.
 *
 * @param request DescribeDBInstancesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeDBInstancesResponse
 */
async function describeDBInstancesWithOptions(request: DescribeDBInstancesRequest, runtime: Util.RuntimeOptions): DescribeDBInstancesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.DBInstanceIds)) {
    query['DBInstanceIds'] = request.DBInstanceIds;
  }
  if (!Util.isUnset(request.DBInstanceStatus)) {
    query['DBInstanceStatus'] = request.DBInstanceStatus;
  }
  if (!Util.isUnset(request.description)) {
    query['Description'] = request.description;
  }
  if (!Util.isUnset(request.pageNumber)) {
    query['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceGroupId)) {
    query['ResourceGroupId'] = request.resourceGroupId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeDBInstances',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries a list of ApsaraDB for ClickHouse clusters.
 *
 * @param request DescribeDBInstancesRequest
 * @return DescribeDBInstancesResponse
 */
async function describeDBInstances(request: DescribeDBInstancesRequest): DescribeDBInstancesResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeDBInstancesWithOptions(request, runtime);
}

model DescribeEndpointsRequest {
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-xxxxx'),
  regionId?: string(name='RegionId', description='The region ID.', example='cn-beijing'),
}

model DescribeEndpointsResponseBody = {
  data?: {
    endpoints?: [ 
      {
        connectionString?: string(name='ConnectionString', description='The endpoint of the cluster.', example='cc-****-clickhouse.clickhouseserver.pre.rds.aliyuncs.com'),
        IPAddress?: string(name='IPAddress', description='The IP address.', example='172.30.XX.XX'),
        netType?: string(name='NetType', description='The network type of the endpoint. Valid values:

*   VPC
*   PUBLIC', example='VPC'),
        ports?: [ 
          {
            port?: int32(name='Port', description='The port used to connect to the cluster. Valid values:

*   8123: This value is returned when the value of Protocol is HttpPort.
*   8443: This value is returned when the value of Protocol is HttpsPort.
*   9000: This value is returned when the value of Protocol is TcpPort.', example='8123'),
            protocol?: string(name='Protocol', description='The protocol type. Valid values:

*   HttpPort
*   HttpsPort
*   TcpPort', example='HttpPort'),
          }
        ](name='Ports', description='The details of the ports.'),
        status?: string(name='Status', description='The state of the cluster.', example='active'),
        vSwitchId?: string(name='VSwitchId', description='The vSwitch ID.', example='vsw-0xi8829****'),
        vpcId?: string(name='VpcId', description='The ID of the virtual private cloud (VPC).', example='vpc-uf61z****'),
        vpcInstanceId?: string(name='VpcInstanceId', description='The VPC ID.', example='vpc-uf61z****'),
      }
    ](name='Endpoints', description='The details of the endpoints.'),
    instanceNetworkType?: string(name='InstanceNetworkType', description='The network type of the cluster. Valid values:

*   **VPC**
*   **PUBLIC**', example='VPC'),
  }(name='Data', description='The returned result.'),
  requestId?: string(name='RequestId', description='The request ID.', example='xxx-xxx-xxx'),
}

model DescribeEndpointsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeEndpointsResponseBody(name='body'),
}

/**
 * @summary Queries the endpoint of an ApsaraDB for ClickHouse cluster.
 *
 * @param request DescribeEndpointsRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeEndpointsResponse
 */
async function describeEndpointsWithOptions(request: DescribeEndpointsRequest, runtime: Util.RuntimeOptions): DescribeEndpointsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeEndpoints',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries the endpoint of an ApsaraDB for ClickHouse cluster.
 *
 * @param request DescribeEndpointsRequest
 * @return DescribeEndpointsResponse
 */
async function describeEndpoints(request: DescribeEndpointsRequest): DescribeEndpointsResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeEndpointsWithOptions(request, runtime);
}

model DescribeProcessListRequest {
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-xxxxx'),
  initialQueryId?: string(name='InitialQueryId', description='The query ID.', example='1'),
  initialUser?: string(name='InitialUser', description='The user who executes the query statement.', example='testuser'),
  keyword?: string(name='Keyword', description='The keyword of the query statement.', example='SELECT'),
  pageNumber?: int32(name='PageNumber', description='The page number.', example='1'),
  pageSize?: int32(name='PageSize', description='The number of entries per page.', example='30'),
  queryDurationMs?: string(name='QueryDurationMs', description='The execution duration of slow SQL queries. Minimum value: 1000. Unit: milliseconds.', example='1000'),
  queryOrder?: long(name='QueryOrder', description='Specifies the columns by which the query results are sorted in descending order.

*   0: The query results are sorted by the query_duration_ms column.
*   1: The query results are sorted by the query_duration_ms and query_start_time columns.
*   2: The query results are sorted by the query_duration_ms, query_start_time, and user columns.', example='id'),
  regionId?: string(name='RegionId', description='The region ID.', example='cn-beijing'),
}

model DescribeProcessListResponseBody = {
  data?: {
    DBInstanceID?: int32(name='DBInstanceID', description='The cluster ID.', example='cc-xxxx'),
    DBInstanceName?: string(name='DBInstanceName', description='The cluster name.', example='test'),
    resultSet?: [ 
      {
        initialAddress?: string(name='InitialAddress', description='The address to which the query statement is sent.', example='0:0:0:0:0:ffff:1edd65ea'),
        initialQueryId?: string(name='InitialQueryId', description='The query ID.', example='\\\\"79f7e40b-87e2-4ef4-b6df-21889a3a030e\\\\"'),
        initialUser?: string(name='InitialUser', description='The user who executes the query statement.', example='bany'),
        query?: string(name='Query', description='The query statement that is running.', example='select * from test'),
        queryDurationMs?: long(name='QueryDurationMs', description='The minimum query duration. Minimum value: **1000**. Unit: milliseconds.', example='1000'),
        queryStartTime?: string(name='QueryStartTime', description='The beginning of the time range to query. The time follows the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time is displayed in UTC.', example='2023-07-23T10:13:23Z'),
      }
    ](name='ResultSet', description='The result sets.'),
    totalCount?: int32(name='TotalCount', description='The total number of entries returned.', example='1'),
  }(name='Data', description='The data returned.'),
  requestId?: string(name='RequestId', description='The request ID.', example='xxx-xxx-xxx'),
}

model DescribeProcessListResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeProcessListResponseBody(name='body'),
}

/**
 * @summary Views running queries.
 *
 * @param request DescribeProcessListRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeProcessListResponse
 */
async function describeProcessListWithOptions(request: DescribeProcessListRequest, runtime: Util.RuntimeOptions): DescribeProcessListResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.initialQueryId)) {
    query['InitialQueryId'] = request.initialQueryId;
  }
  if (!Util.isUnset(request.initialUser)) {
    query['InitialUser'] = request.initialUser;
  }
  if (!Util.isUnset(request.keyword)) {
    query['Keyword'] = request.keyword;
  }
  if (!Util.isUnset(request.pageNumber)) {
    query['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.queryDurationMs)) {
    query['QueryDurationMs'] = request.queryDurationMs;
  }
  if (!Util.isUnset(request.queryOrder)) {
    query['QueryOrder'] = request.queryOrder;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeProcessList',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Views running queries.
 *
 * @param request DescribeProcessListRequest
 * @return DescribeProcessListResponse
 */
async function describeProcessList(request: DescribeProcessListRequest): DescribeProcessListResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeProcessListWithOptions(request, runtime);
}

model DescribeSecurityIPListRequest {
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-bp100p4q1g9z3****'),
  regionId?: string(name='RegionId', description='The region ID.', example='cn-hangzhou'),
}

model DescribeSecurityIPListResponseBody = {
  data?: {
    DBInstanceID?: int32(name='DBInstanceID', description='The cluster ID.', example='cc-bp100p4q1g9z3****'),
    DBInstanceName?: string(name='DBInstanceName', description='The cluster name.', example='TestCluster'),
    groupItems?: [ 
      {
        groupName?: string(name='GroupName', description='The name of the whitelist.', example='default'),
        groupTag?: string(name='GroupTag', description='The tag of the whitelist.', example='test'),
        securityIPList?: string(name='SecurityIPList', description='The IP addresses and CIDR blocks in the whitelist.', example='127.0.XX.XX'),
        securityIPType?: string(name='SecurityIPType', description='The IP address type.', example='ipv4'),
        whitelistNetType?: string(name='WhitelistNetType', description='The network type of the whitelist.', example='mix'),
      }
    ](name='GroupItems', description='The details about the whitelists.'),
  }(name='Data', description='The data returned.'),
  requestId?: string(name='RequestId', description='The request ID.', example='D0CEC6AC-7760-409A-A0D5-E6CD8660E9CC'),
}

model DescribeSecurityIPListResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeSecurityIPListResponseBody(name='body'),
}

/**
 * @summary Queries the whitelist of an ApsaraDB for ClickHouse cluster.
 *
 * @param request DescribeSecurityIPListRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeSecurityIPListResponse
 */
async function describeSecurityIPListWithOptions(request: DescribeSecurityIPListRequest, runtime: Util.RuntimeOptions): DescribeSecurityIPListResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeSecurityIPList',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries the whitelist of an ApsaraDB for ClickHouse cluster.
 *
 * @param request DescribeSecurityIPListRequest
 * @return DescribeSecurityIPListResponse
 */
async function describeSecurityIPList(request: DescribeSecurityIPListRequest): DescribeSecurityIPListResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeSecurityIPListWithOptions(request, runtime);
}

model DescribeSlowLogRecordsRequest {
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-bp100p4q1g9z3****'),
  endTime?: string(name='EndTime', description='The end of the time range to query. Specify the time in the yyyy-MM-dd hh:mm:ss format. The time must be in UTC.', example='2023-09-15 16:00:00'),
  pageNumber?: int32(name='PageNumber', description='The page number.', example='1'),
  pageSize?: int32(name='PageSize', description='The number of entries per page. Valid values:

*   30 (default)
*   50
*   100', example='30'),
  queryDurationMs?: string(name='QueryDurationMs', description='The execution duration of slow SQL queries. Minimum value: **1000**. Unit: milliseconds.', example='3000'),
  regionId?: string(name='RegionId', description='The region ID.', example='cn-hangzhou'),
  startTime?: string(name='StartTime', description='The beginning of the time range to query. Specify the time in the yyyy-MM-dd hh:mm:ss format. The time must be in UTC.', example='2023-09-11 16:00:00'),
}

model DescribeSlowLogRecordsResponseBody = {
  data?: {
    DBInstanceID?: int32(name='DBInstanceID', description='The cluster ID.', example='cc-bp100p4q1g9z32****'),
    DBInstanceName?: string(name='DBInstanceName', description='The cluster name.', example='TestCluster'),
    resultSet?: [ 
      {
        initialAddress?: string(name='InitialAddress', description='The address to which the query statement is sent.', example='0:0:0:0:0:ffff:1edd65ea'),
        initialQueryId?: string(name='InitialQueryId', description='The query ID.', example='\\\\"ae915a3ad30e77e67a7215d05b658cc6\\\\"'),
        initialUser?: string(name='InitialUser', description='The user who executes the query statement.', example='bany'),
        memoryUsage?: long(name='MemoryUsage', description='The peak memory usage for the query. Unit: bytes.', example='4941696'),
        query?: string(name='Query', description='The query statement that is running.', example='select * from test'),
        queryDurationMs?: long(name='QueryDurationMs', description='The execution duration of slow SQL queries. Minimum value: **1000**. Unit: milliseconds.', example='3000'),
        queryStartTime?: string(name='QueryStartTime', description='The beginning of the time range to query. The time is in the yyyy-MM-dd hh:mm:ss format. The time is displayed in UTC.', example='2023-09-11 16:00:00'),
        readBytes?: long(name='ReadBytes', description='The size of the data that is scanned. Unit: bytes.', example='4507128020832'),
        readRows?: long(name='ReadRows', description='The number of read rows.', example='10'),
        resultBytes?: long(name='ResultBytes', description='The size of the result data. Unit: bytes.', example='10'),
        type?: string(name='Type', description='The type of the slow query logs.', example='ExceptionWhileProcessing'),
      }
    ](name='ResultSet', description='The result sets.'),
    totalCount?: int32(name='TotalCount', description='The total number of entries returned.', example='1'),
  }(name='Data', description='The data returned.'),
  requestId?: string(name='RequestId', description='The request ID.', example='DF203CC8-5F68-5E3F-8050-3C77DD65731A'),
}

model DescribeSlowLogRecordsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeSlowLogRecordsResponseBody(name='body'),
}

/**
 * @summary Queries the details of slow query logs.
 *
 * @param request DescribeSlowLogRecordsRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeSlowLogRecordsResponse
 */
async function describeSlowLogRecordsWithOptions(request: DescribeSlowLogRecordsRequest, runtime: Util.RuntimeOptions): DescribeSlowLogRecordsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.endTime)) {
    query['EndTime'] = request.endTime;
  }
  if (!Util.isUnset(request.pageNumber)) {
    query['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.queryDurationMs)) {
    query['QueryDurationMs'] = request.queryDurationMs;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.startTime)) {
    query['StartTime'] = request.startTime;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeSlowLogRecords',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries the details of slow query logs.
 *
 * @param request DescribeSlowLogRecordsRequest
 * @return DescribeSlowLogRecordsResponse
 */
async function describeSlowLogRecords(request: DescribeSlowLogRecordsRequest): DescribeSlowLogRecordsResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeSlowLogRecordsWithOptions(request, runtime);
}

model DescribeSlowLogTrendRequest {
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-bp100p4q1g9z3****'),
  endTime?: string(name='EndTime', description='The end of the time range to query. Specify the time in the yyyy-MM-dd hh:mm:ss format. The time must be in UTC.', example='2023-06-07 10:03:00'),
  product?: string(name='Product', description='The code of the cloud service.', example='clickhouse'),
  queryDurationMs?: string(name='QueryDurationMs', description='The execution duration of slow SQL queries. Minimum value: **1000**. Unit: milliseconds.', example='3000'),
  regionId?: string(name='RegionId', description='The region ID.', example='cn-hangzhou'),
  startTime?: string(name='StartTime', description='The start of the time range to query. Specify the time in the yyyy-MM-dd hh:mm:ss format. The time must be in UTC.', example='2023-04-13 17:48:00'),
}

model DescribeSlowLogTrendResponseBody = {
  data?: {
    DBInstanceID?: int32(name='DBInstanceID', description='The cluster ID.', example='cc-bp100p4q1g9z3****'),
    DBInstanceName?: string(name='DBInstanceName', description='The cluster name.', example='clusterTest'),
    resultSet?: [ 
      {
        avgQueryDurationMs?: long(name='AvgQueryDurationMs', description='The average execution duration of slow SQL queries. Minimum value: **1000**. Unit: milliseconds.', example='2000'),
        cnt?: long(name='Cnt', description='The total number of SQL queries within the specified time range.', example='1'),
        maxQueryDurationMs?: long(name='MaxQueryDurationMs', description='The maximum execution duration of slow SQL queries. Minimum value: **1000**. Unit: milliseconds.', example='3000'),
        minQueryDurationMs?: long(name='MinQueryDurationMs', description='The minimum execution duration of slow SQL queries. Minimum value: **1000**. Unit: milliseconds.', example='1000'),
        queryStartTime?: string(name='QueryStartTime', description='The beginning of the time range to query. The time is in the yyyy-MM-dd hh:mm:ss format. The time is displayed in UTC.', example='2023-04-13 17:48:00'),
      }
    ](name='ResultSet', description='The result sets.'),
  }(name='Data', description='The returned result.'),
  requestId?: string(name='RequestId', description='The request ID.', example='7D3ECB0E-98CA-5E08-A9CA-F70C5A1E9BDF'),
}

model DescribeSlowLogTrendResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeSlowLogTrendResponseBody(name='body'),
}

/**
 * @summary Queries the trend of slow query logs.
 *
 * @param request DescribeSlowLogTrendRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeSlowLogTrendResponse
 */
async function describeSlowLogTrendWithOptions(request: DescribeSlowLogTrendRequest, runtime: Util.RuntimeOptions): DescribeSlowLogTrendResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.endTime)) {
    query['EndTime'] = request.endTime;
  }
  if (!Util.isUnset(request.product)) {
    query['Product'] = request.product;
  }
  if (!Util.isUnset(request.queryDurationMs)) {
    query['QueryDurationMs'] = request.queryDurationMs;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.startTime)) {
    query['StartTime'] = request.startTime;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeSlowLogTrend',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries the trend of slow query logs.
 *
 * @param request DescribeSlowLogTrendRequest
 * @return DescribeSlowLogTrendResponse
 */
async function describeSlowLogTrend(request: DescribeSlowLogTrendRequest): DescribeSlowLogTrendResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeSlowLogTrendWithOptions(request, runtime);
}

model KillProcessRequest {
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-xxxxxxx'),
  initialQueryId?: string(name='InitialQueryId', description='The query ID.', example='1'),
  regionId?: string(name='RegionId', description='The region ID.', example='cn-hangzhou'),
}

model KillProcessResponseBody = {
  data?: {
    count?: long(name='Count', description='The number of queries that are terminated.', example='1'),
    DBInstanceID?: int32(name='DBInstanceID', description='The cluster ID.', example='cc-xxxxxxx'),
    DBInstanceName?: string(name='DBInstanceName', description='The cluster name.', example='cc-xxxxxxx'),
  }(name='Data', description='The data returned.'),
  requestId?: string(name='RequestId', description='The request ID.', example='xxx-xxx-xxx'),
}

model KillProcessResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: KillProcessResponseBody(name='body'),
}

/**
 * @summary Terminates an ongoing query.
 *
 * @param request KillProcessRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return KillProcessResponse
 */
async function killProcessWithOptions(request: KillProcessRequest, runtime: Util.RuntimeOptions): KillProcessResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.initialQueryId)) {
    query['InitialQueryId'] = request.initialQueryId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'KillProcess',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Terminates an ongoing query.
 *
 * @param request KillProcessRequest
 * @return KillProcessResponse
 */
async function killProcess(request: KillProcessRequest): KillProcessResponse {
  var runtime = new Util.RuntimeOptions{};
  return killProcessWithOptions(request, runtime);
}

model ModifyAccountAuthorityRequest {
  account?: string(name='Account', description='The name of the database account.

This parameter is required.', example='test1'),
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-bp100p4q1g9z3****'),
  dmlAuthSetting?: {
    allowDatabases?: [ string ](name='AllowDatabases', description='The databases on which you want to grant permissions. Separate multiple databases with commas (,).'),
    allowDictionaries?: [ string ](name='AllowDictionaries', description='The dictionaries on which you want to grant permissions. Separate multiple dictionaries with commas (,).'),
    ddlAuthority?: boolean(name='DdlAuthority', description='Specifies whether to grant the DDL permissions to the database account. Valid values:

*   **true**: The account has the permissions to execute DDL statements.
*   **false**: The account does not have the permissions to execute DDL statements.

This parameter is required.', example='true'),
    dmlAuthority?: int32(name='DmlAuthority', description='Specifies whether to grant the DML permissions to the database account. Valid values:

*   **0**: The account has the permissions to read data from the database, write data to the database, and modify the settings of the database.
*   **1**: The account only has the permissions to read data from the database.
*   **2**: The account only has the permissions to read data from the database and modify the settings of the database.

This parameter is required.', example='0'),
  }(name='DmlAuthSetting', description='The information about permissions.

This parameter is required.'),
  regionId?: string(name='RegionId', description='The region ID.

This parameter is required.', example='cn-hangzhou'),
}

model ModifyAccountAuthorityShrinkRequest {
  account?: string(name='Account', description='The name of the database account.

This parameter is required.', example='test1'),
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-bp100p4q1g9z3****'),
  dmlAuthSettingShrink?: string(name='DmlAuthSetting', description='The information about permissions.

This parameter is required.'),
  regionId?: string(name='RegionId', description='The region ID.

This parameter is required.', example='cn-hangzhou'),
}

model ModifyAccountAuthorityResponseBody = {
  data?: {
    account?: string(name='Account', description='The name of the database account.', example='test1'),
    DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.', example='cc-bp100p4q1g9z3****'),
  }(name='Data', description='The result returned.'),
  requestId?: string(name='RequestId', description='The request ID.', example='05321590-BB65-4720-8CB6-8218E041CDD0'),
}

model ModifyAccountAuthorityResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ModifyAccountAuthorityResponseBody(name='body'),
}

/**
 * @summary Modifies the permissions of a database account.
 *
 * @param tmpReq ModifyAccountAuthorityRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ModifyAccountAuthorityResponse
 */
async function modifyAccountAuthorityWithOptions(tmpReq: ModifyAccountAuthorityRequest, runtime: Util.RuntimeOptions): ModifyAccountAuthorityResponse {
  Util.validateModel(tmpReq);
  var request = new ModifyAccountAuthorityShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.dmlAuthSetting)) {
    request.dmlAuthSettingShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.dmlAuthSetting, 'DmlAuthSetting', 'json');
  }
  var query = {};
  if (!Util.isUnset(request.account)) {
    query['Account'] = request.account;
  }
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.dmlAuthSettingShrink)) {
    query['DmlAuthSetting'] = request.dmlAuthSettingShrink;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ModifyAccountAuthority',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Modifies the permissions of a database account.
 *
 * @param request ModifyAccountAuthorityRequest
 * @return ModifyAccountAuthorityResponse
 */
async function modifyAccountAuthority(request: ModifyAccountAuthorityRequest): ModifyAccountAuthorityResponse {
  var runtime = new Util.RuntimeOptions{};
  return modifyAccountAuthorityWithOptions(request, runtime);
}

model ModifyAccountDescriptionRequest {
  account?: string(name='Account', description='The name of the account.

This parameter is required.', example='testuser'),
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-xxxxxxx'),
  description?: string(name='Description', description='The description of the account.

This parameter is required.', example='test'),
  regionId?: string(name='RegionId', description='The region ID.

This parameter is required.', example='cn-hangzhou'),
}

model ModifyAccountDescriptionResponseBody = {
  data?: {
    account?: string(name='Account', description='The name of the database account.', example='testuser'),
    DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.', example='cc-xxxxx'),
  }(name='Data', description='The returned data.'),
  requestId?: string(name='RequestId', description='The request ID.', example='xxx-xxx-xxx'),
}

model ModifyAccountDescriptionResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ModifyAccountDescriptionResponseBody(name='body'),
}

/**
 * @summary Modifies the description of a database account.
 *
 * @param request ModifyAccountDescriptionRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ModifyAccountDescriptionResponse
 */
async function modifyAccountDescriptionWithOptions(request: ModifyAccountDescriptionRequest, runtime: Util.RuntimeOptions): ModifyAccountDescriptionResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.account)) {
    query['Account'] = request.account;
  }
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.description)) {
    query['Description'] = request.description;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ModifyAccountDescription',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Modifies the description of a database account.
 *
 * @param request ModifyAccountDescriptionRequest
 * @return ModifyAccountDescriptionResponse
 */
async function modifyAccountDescription(request: ModifyAccountDescriptionRequest): ModifyAccountDescriptionResponse {
  var runtime = new Util.RuntimeOptions{};
  return modifyAccountDescriptionWithOptions(request, runtime);
}

model ModifyDBInstanceAttributeRequest {
  attributeType?: string(name='AttributeType', description='The configuration that you want to modify.

*   MaintainTime: the O\\\\&M time
*   DBInstanceDescription: the cluster name

This parameter is required.', example='DBInstanceDescription'),
  attributeValue?: string(name='AttributeValue', description='The new value of the configuration.

This parameter is required.', example='test'),
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-xxxxx'),
  product?: string(name='Product', description='The code of the cloud service.', example='clickhouse'),
  regionId?: string(name='RegionId', description='The region ID.

This parameter is required.', example='cn-hangzhou'),
}

model ModifyDBInstanceAttributeResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='xxx-xxx-xxx'),
}

model ModifyDBInstanceAttributeResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ModifyDBInstanceAttributeResponseBody(name='body'),
}

/**
 * @summary Modifies the configurations of an ApsaraDB for ClickHouse cluster.
 *
 * @param request ModifyDBInstanceAttributeRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ModifyDBInstanceAttributeResponse
 */
async function modifyDBInstanceAttributeWithOptions(request: ModifyDBInstanceAttributeRequest, runtime: Util.RuntimeOptions): ModifyDBInstanceAttributeResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.attributeType)) {
    query['AttributeType'] = request.attributeType;
  }
  if (!Util.isUnset(request.attributeValue)) {
    query['AttributeValue'] = request.attributeValue;
  }
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.product)) {
    query['Product'] = request.product;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ModifyDBInstanceAttribute',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Modifies the configurations of an ApsaraDB for ClickHouse cluster.
 *
 * @param request ModifyDBInstanceAttributeRequest
 * @return ModifyDBInstanceAttributeResponse
 */
async function modifyDBInstanceAttribute(request: ModifyDBInstanceAttributeRequest): ModifyDBInstanceAttributeResponse {
  var runtime = new Util.RuntimeOptions{};
  return modifyDBInstanceAttributeWithOptions(request, runtime);
}

model ModifyDBInstanceClassRequest {
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-xxxxxxx'),
  regionId?: string(name='RegionId', description='The region ID.', example='cn-hangzhou'),
  scaleMax?: long(name='ScaleMax', description='The maximum capacity for elastic scaling.', example='32'),
  scaleMin?: long(name='ScaleMin', description='The minimum capacity for elastic scaling.', example='2'),
}

model ModifyDBInstanceClassResponseBody = {
  data?: {
    DBInstanceID?: long(name='DBInstanceID', description='The cluster ID.', example='cc-xxxxxxx'),
    DBInstanceName?: string(name='DBInstanceName', description='The cluster name.', example='cc-xxxxxxx'),
    scaleMax?: long(name='ScaleMax', description='The maximum capacity for elastic scaling.', example='32'),
    scaleMin?: long(name='ScaleMin', description='The minimum capacity for elastic scaling.', example='2'),
    taskId?: long(name='TaskId', description='The task ID.', example='10000****'),
  }(name='Data', description='The returned result.'),
  requestId?: string(name='RequestId', description='The request ID.', example='xxx-xxx-xxx'),
}

model ModifyDBInstanceClassResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ModifyDBInstanceClassResponseBody(name='body'),
}

/**
 * @summary Modifies the elastic scaling settings of an ApsaraDB for ClickHouse cluster.
 *
 * @param request ModifyDBInstanceClassRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ModifyDBInstanceClassResponse
 */
async function modifyDBInstanceClassWithOptions(request: ModifyDBInstanceClassRequest, runtime: Util.RuntimeOptions): ModifyDBInstanceClassResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.scaleMax)) {
    query['ScaleMax'] = request.scaleMax;
  }
  if (!Util.isUnset(request.scaleMin)) {
    query['ScaleMin'] = request.scaleMin;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ModifyDBInstanceClass',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Modifies the elastic scaling settings of an ApsaraDB for ClickHouse cluster.
 *
 * @param request ModifyDBInstanceClassRequest
 * @return ModifyDBInstanceClassResponse
 */
async function modifyDBInstanceClass(request: ModifyDBInstanceClassRequest): ModifyDBInstanceClassResponse {
  var runtime = new Util.RuntimeOptions{};
  return modifyDBInstanceClassWithOptions(request, runtime);
}

model ModifyDBInstanceConnectionStringRequest {
  connectionString?: string(name='ConnectionString', description='The endpoint of the cluster.', example='cc-2ze34****-clickhouse..clickhouseserver.pre.rds.aliyuncs.com'),
  connectionStringPrefix?: string(name='ConnectionStringPrefix', description='The prefix of the endpoint that is used to connect to the database.', example='cc-****-clickhouse'),
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-xxxxx'),
  DBInstanceNetType?: string(name='DBInstanceNetType'),
  disablePorts?: string(name='DisablePorts', description='*   The database ports that you want to disable. Separate multiple ports with commas (,).

*   This parameter is supported only for clusters whose minor engine version is 24.10.1.11098_1 or later.

    **

    **Note** If you create a cluster whose minor engine version is earlier than 24.10.1.11098_1 and you update the minor engine version to 24.10.1.11098_1 or later, the cluster still does not support this parameter.', example='9001,8123'),
  regionId?: string(name='RegionId', description='The region ID.', example='cn-hangzhou'),
}

model ModifyDBInstanceConnectionStringResponseBody = {
  data?: {
    connectionString?: string(name='ConnectionString', description='The endpoint of the cluster.', example='cc-2ze34****-clickhouse..clickhouseserver.pre.rds.aliyuncs.com'),
    DBInstanceID?: int32(name='DBInstanceID', description='The cluster ID.', example='cc-xxxxx'),
    DBInstanceName?: string(name='DBInstanceName', description='The cluster name.', example='cc-xxxxx'),
    disabledPorts?: string(name='DisabledPorts', description='The disabled database ports.', example='9001,8123'),
  }(name='Data', description='The data returned.'),
  requestId?: string(name='RequestId', description='The request ID.', example='xxx-xxx-xxx'),
}

model ModifyDBInstanceConnectionStringResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ModifyDBInstanceConnectionStringResponseBody(name='body'),
}

/**
 * @summary Modifies the endpoint of an ApsaraDB for ClickHouse cluster.
 *
 * @param request ModifyDBInstanceConnectionStringRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ModifyDBInstanceConnectionStringResponse
 */
async function modifyDBInstanceConnectionStringWithOptions(request: ModifyDBInstanceConnectionStringRequest, runtime: Util.RuntimeOptions): ModifyDBInstanceConnectionStringResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.connectionString)) {
    query['ConnectionString'] = request.connectionString;
  }
  if (!Util.isUnset(request.connectionStringPrefix)) {
    query['ConnectionStringPrefix'] = request.connectionStringPrefix;
  }
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.DBInstanceNetType)) {
    query['DBInstanceNetType'] = request.DBInstanceNetType;
  }
  if (!Util.isUnset(request.disablePorts)) {
    query['DisablePorts'] = request.disablePorts;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ModifyDBInstanceConnectionString',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Modifies the endpoint of an ApsaraDB for ClickHouse cluster.
 *
 * @param request ModifyDBInstanceConnectionStringRequest
 * @return ModifyDBInstanceConnectionStringResponse
 */
async function modifyDBInstanceConnectionString(request: ModifyDBInstanceConnectionStringRequest): ModifyDBInstanceConnectionStringResponse {
  var runtime = new Util.RuntimeOptions{};
  return modifyDBInstanceConnectionStringWithOptions(request, runtime);
}

model ModifySecurityIPListRequest {
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-xxxxx'),
  groupName?: string(name='GroupName', description='The name of the whitelist whose settings you want to modify.', example='test'),
  modifyMode?: string(name='ModifyMode', description='The modification mode.

*   0: overwrites the original IP addresses and CIDR blocks in the whitelist.
*   1: adds the IP addresses and CIDR blocks to the whitelist.
*   2: removes the IP addresses and CIDR blocks from the whitelist.

>  We recommend that you set the value to 0.', example='0'),
  regionId?: string(name='RegionId', description='The region ID.', example='cn-beijing'),
  securityIPList?: string(name='SecurityIPList', description='The IP addresses and CIDR blocks in the whitelist.', example='192.168.0.0/24,172.16.0.0/24'),
}

model ModifySecurityIPListResponseBody = {
  data?: {
    DBInstanceID?: int32(name='DBInstanceID', description='The cluster ID.', example='cc-xxxx'),
    DBInstanceName?: string(name='DBInstanceName', description='The cluster name.', example='cc-xxxx'),
    groupName?: string(name='GroupName', description='The name of the whitelist.', example='test'),
    groupTag?: string(name='GroupTag', description='The tag of the whitelist.', example='test'),
    securityIPList?: string(name='SecurityIPList', description='The IP addresses and CIDR blocks in the whitelist.', example='192.168.0.0/24,172.16.0.0/24'),
    securityIPType?: string(name='SecurityIPType', description='The IP address type.', example='ipv4'),
    taskId?: int32(name='TaskId', description='The task ID.', example='1'),
    whitelistNetType?: string(name='WhitelistNetType', description='The network type of the whitelist.', example='mix'),
  }(name='Data', description='The returned result.'),
  requestId?: string(name='RequestId', description='The request ID.', example='xxx-xxx-xxx'),
}

model ModifySecurityIPListResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ModifySecurityIPListResponseBody(name='body'),
}

/**
 * @summary Modifies the whitelist settings of an ApsaraDB for ClickHouse cluster.
 *
 * @param request ModifySecurityIPListRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ModifySecurityIPListResponse
 */
async function modifySecurityIPListWithOptions(request: ModifySecurityIPListRequest, runtime: Util.RuntimeOptions): ModifySecurityIPListResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.groupName)) {
    query['GroupName'] = request.groupName;
  }
  if (!Util.isUnset(request.modifyMode)) {
    query['ModifyMode'] = request.modifyMode;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.securityIPList)) {
    query['SecurityIPList'] = request.securityIPList;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ModifySecurityIPList',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Modifies the whitelist settings of an ApsaraDB for ClickHouse cluster.
 *
 * @param request ModifySecurityIPListRequest
 * @return ModifySecurityIPListResponse
 */
async function modifySecurityIPList(request: ModifySecurityIPListRequest): ModifySecurityIPListResponse {
  var runtime = new Util.RuntimeOptions{};
  return modifySecurityIPListWithOptions(request, runtime);
}

model ResetAccountPasswordRequest {
  account?: string(name='Account', description='The name of the database account.

This parameter is required.', example='test1'),
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-bp100p4q1g9z3****'),
  password?: string(name='Password', description='The password of the database account. The password must meet the following requirements:

- The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters.
- The following special characters are supported: ! @ # $ % ^ & * ( ) _ + - =
- The password must be 8 to 32 characters in length.

This parameter is required.', example='123456Aa'),
  product?: string(name='Product', description='The service name.', example='clickhouse'),
  regionId?: string(name='RegionId', description='The region ID.

This parameter is required.', example='cn-hangzhou'),
}

model ResetAccountPasswordResponseBody = {
  data?: {
    account?: string(name='Account', description='The name of the account.', example='test1'),
    DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.', example='cc-bp100p4q1g9z3****'),
  }(name='Data', description='The result returned.'),
  requestId?: string(name='RequestId', description='The request ID.', example='5A6A077A-577C-536E-AC13-8E715D7A34C8'),
}

model ResetAccountPasswordResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ResetAccountPasswordResponseBody(name='body'),
}

/**
 * @summary Resets the password of a database account for an ApsaraDB for ClickHouse Enterprise Edition cluster.
 *
 * @param request ResetAccountPasswordRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ResetAccountPasswordResponse
 */
async function resetAccountPasswordWithOptions(request: ResetAccountPasswordRequest, runtime: Util.RuntimeOptions): ResetAccountPasswordResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.account)) {
    query['Account'] = request.account;
  }
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.password)) {
    query['Password'] = request.password;
  }
  if (!Util.isUnset(request.product)) {
    query['Product'] = request.product;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ResetAccountPassword',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Resets the password of a database account for an ApsaraDB for ClickHouse Enterprise Edition cluster.
 *
 * @param request ResetAccountPasswordRequest
 * @return ResetAccountPasswordResponse
 */
async function resetAccountPassword(request: ResetAccountPasswordRequest): ResetAccountPasswordResponse {
  var runtime = new Util.RuntimeOptions{};
  return resetAccountPasswordWithOptions(request, runtime);
}

model RestartDBInstanceRequest {
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-bp100p4q1g9z3****'),
  regionId?: string(name='RegionId', description='The region ID.', example='cn-hangzhou'),
}

model RestartDBInstanceResponseBody = {
  data?: {
    DBInstanceID?: long(name='DBInstanceID', description='The cluster ID.', example='cc-bp100p4q1g9z3****'),
    DBInstanceName?: string(name='DBInstanceName', description='The cluster name.', example='test1'),
    taskId?: long(name='TaskId', description='The task ID.', example='100001080'),
  }(name='Data', description='The data returned.'),
  requestId?: string(name='RequestId', description='The request ID.', example='D0CEC6AC-7760-409A-A0D5-E6CD8660E9CC'),
}

model RestartDBInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: RestartDBInstanceResponseBody(name='body'),
}

/**
 * @summary Restarts an ApsaraDB for ClickHouse Enterprise Edition cluster.
 *
 * @param request RestartDBInstanceRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return RestartDBInstanceResponse
 */
async function restartDBInstanceWithOptions(request: RestartDBInstanceRequest, runtime: Util.RuntimeOptions): RestartDBInstanceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'RestartDBInstance',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Restarts an ApsaraDB for ClickHouse Enterprise Edition cluster.
 *
 * @param request RestartDBInstanceRequest
 * @return RestartDBInstanceResponse
 */
async function restartDBInstance(request: RestartDBInstanceRequest): RestartDBInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return restartDBInstanceWithOptions(request, runtime);
}

model StartDBInstanceRequest {
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-bp100p4q1g9z3****'),
  regionId?: string(name='RegionId', description='The region ID.', example='cn-hangzhou'),
}

model StartDBInstanceResponseBody = {
  data?: {
    DBInstanceID?: long(name='DBInstanceID', description='The cluster ID.', example='cc-bp100p4q1g9z3****'),
    DBInstanceName?: string(name='DBInstanceName', description='The cluster name.', example='test1'),
    taskId?: long(name='TaskId', description='The task ID.', example='100000837'),
  }(name='Data', description='The data returned.'),
  requestId?: string(name='RequestId', description='The request ID.', example='F5178C10-1407-4987-9133-DE4DC9119F76'),
}

model StartDBInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: StartDBInstanceResponseBody(name='body'),
}

/**
 * @summary Starts an ApsaraDB for ClickHouse Enterprise Edition cluster.
 *
 * @param request StartDBInstanceRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return StartDBInstanceResponse
 */
async function startDBInstanceWithOptions(request: StartDBInstanceRequest, runtime: Util.RuntimeOptions): StartDBInstanceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'StartDBInstance',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Starts an ApsaraDB for ClickHouse Enterprise Edition cluster.
 *
 * @param request StartDBInstanceRequest
 * @return StartDBInstanceResponse
 */
async function startDBInstance(request: StartDBInstanceRequest): StartDBInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return startDBInstanceWithOptions(request, runtime);
}

model StopDBInstanceRequest {
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-bp100p4q1g9z3****'),
  regionId?: string(name='RegionId', description='The region ID.', example='cn-hangzhou'),
}

model StopDBInstanceResponseBody = {
  data?: {
    DBInstanceID?: long(name='DBInstanceID', description='The cluster ID.', example='cc-bp100p4q1g9z3****'),
    DBInstanceName?: string(name='DBInstanceName', description='The cluster name.', example='test1'),
    taskId?: long(name='TaskId', description='The task ID.', example='100000785'),
  }(name='Data', description='The data returned.'),
  requestId?: string(name='RequestId', description='The request ID.', example='2FED790E-FB61-4721-8C1C-07C627FA5A19'),
}

model StopDBInstanceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: StopDBInstanceResponseBody(name='body'),
}

/**
 * @summary Stops an ApsaraDB for ClickHouse Enterprise Edition cluster.
 *
 * @param request StopDBInstanceRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return StopDBInstanceResponse
 */
async function stopDBInstanceWithOptions(request: StopDBInstanceRequest, runtime: Util.RuntimeOptions): StopDBInstanceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'StopDBInstance',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Stops an ApsaraDB for ClickHouse Enterprise Edition cluster.
 *
 * @param request StopDBInstanceRequest
 * @return StopDBInstanceResponse
 */
async function stopDBInstance(request: StopDBInstanceRequest): StopDBInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return stopDBInstanceWithOptions(request, runtime);
}

model UpgradeMinorVersionRequest {
  DBInstanceId?: string(name='DBInstanceId', description='The cluster ID.

This parameter is required.', example='cc-bp1jyis8p15we****'),
  regionId?: string(name='RegionId', description='The region ID.', example='cn-hangzhou'),
  switchTime?: string(name='SwitchTime', description='The update time. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC.

>  If you set SwitchTimeMode to SpecifyTime, you must configure this parameter to specify the update time.', example='2023-01-09T05:00:00Z'),
  switchTimeMode?: string(name='SwitchTimeMode', description='Specifies whether to update the minor engine version of the cluster immediately. Valid values:

*   **Immediate**: The system immediately performs the update.
*   **MaintainTime**: The system performs the update during the specified maintenance window.
*   **SpecifyTime**: The system performs the update at a specified time.', example='Immediate'),
  targetMinorVersion?: string(name='TargetMinorVersion', description='The minor engine version to which you want to update.

>  By default, TargetMinorVersion is not set and the minor engine version of the cluster is updated to the latest version.', example='23.8.1.41495_6'),
}

model UpgradeMinorVersionResponseBody = {
  data?: {
    DBInstanceName?: string(name='DBInstanceName', description='The instance ID.', example='cc-uf6x229yeq166****'),
  }(name='Data', description='The returned result.'),
  requestId?: string(name='RequestId', description='The request ID.', example='FE242962-6DA3-5FC8-9691-37B62A3210F7'),
}

model UpgradeMinorVersionResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UpgradeMinorVersionResponseBody(name='body'),
}

/**
 * @summary Updates the minor engine version of an ApsaraDB for ClickHouse cluster that runs Enterprise Edition.
 *
 * @param request UpgradeMinorVersionRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return UpgradeMinorVersionResponse
 */
async function upgradeMinorVersionWithOptions(request: UpgradeMinorVersionRequest, runtime: Util.RuntimeOptions): UpgradeMinorVersionResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.switchTime)) {
    query['SwitchTime'] = request.switchTime;
  }
  if (!Util.isUnset(request.switchTimeMode)) {
    query['SwitchTimeMode'] = request.switchTimeMode;
  }
  if (!Util.isUnset(request.targetMinorVersion)) {
    query['TargetMinorVersion'] = request.targetMinorVersion;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'UpgradeMinorVersion',
    version = '2023-05-22',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Updates the minor engine version of an ApsaraDB for ClickHouse cluster that runs Enterprise Edition.
 *
 * @param request UpgradeMinorVersionRequest
 * @return UpgradeMinorVersionResponse
 */
async function upgradeMinorVersion(request: UpgradeMinorVersionRequest): UpgradeMinorVersionResponse {
  var runtime = new Util.RuntimeOptions{};
  return upgradeMinorVersionWithOptions(request, runtime);
}

